// pages/admin/pages/reviewOrder/reviewOrder.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId: "52645312",
    /* 审核状态选择 */
    // 备注信息
    remarks: '',
    items: [{
        value: '通过',
        checked: 'true'
      },
      {
        value: '拒绝',
      }
    ],
    //订单
    order: null,
    status:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let order = JSON.parse(options.order);
    this.setData({
      order: order
    })
  },
  /**
   * 审核状态改变
   */
  radioChange: function(e) {
    console.log('radio发生change事件，携带value值为：', e.detail);
    let status = e.detail.value
    if(status=='通过'){
      this.setData({
        status:1
      });
    }else if(status=='拒绝'){
      this.setData({
        status: 2
      });
    }
    

  },
  confirm() {
    //提交审核
    let _this = this;
    let orderId =this.data.order.id;
    let status = this.data.status;
    let address = this.data.order.address;
    let tel = this.data.order.userTel;
    let remarks = this.data.remarks==null||this.data.remarks=='' ? "" : this.data.remarks;
    var header = app.globalData.header; //获取app.js中的请求头
    wx.request({
      url: app.globalData.ipPort +'/front/order/auth',
      method: 'post',
      header: {
        'Cookie': app.globalData.header.Cookie,
        'Content-Type': 'application/x-www-form-urlencoded' 
      },
      data: {
        orderId: orderId,
        status:status,
        remarks:remarks,
        address:address,
        tel:tel
      },
      success(res) {
        if (res.data.code == 200) {
          var data = res.data.data

          _this.setData({
            orderList: res.data.data
          })
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: "none"
          })
        }
      },
      fail(res) {
        wx.showToast({
          title: res.msg,
          icon: "none"
        })
      }
    })
  },
  /**
   * 备注输入框输入内容监听函数
   */
  textareInput(event) {
    console.log(event.detail.value)
    this.setData({
      remarks: event.detail.value
    })
  }

})